-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds view_closed support #276
Adds view_closed support #276
Conversation
Codecov Report
@@ Coverage Diff @@
## master #276 +/- ##
==========================================
+ Coverage 72.65% 73.71% +1.06%
==========================================
Files 7 7
Lines 501 506 +5
Branches 142 145 +3
==========================================
+ Hits 364 373 +9
+ Misses 105 101 -4
Partials 32 32
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from this comment in #269, LGTM - https://github.com/slackapi/bolt/pull/269/files#r331281150
@@ -437,20 +437,19 @@ describe('App', () => { | |||
respond: noop, | |||
ack: noop, | |||
}, | |||
// TODO: https://github.com/slackapi/bolt/issues/263 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we also can verify if the condition works by having the following lines in the test suite.
// add a new routing definition
app.view({callback_id: 'view_callback_id', type: 'view_closed'}, ({ }) => { viewFn(); })
// modify assert.equal(viewFn.callCount, 1); as below:
assert.equal(viewFn.callCount, 2);
app.view('view_callback_id', ({ }) => { viewFn(); }); | ||
app.view({ callback_id: 'view_callback_id', type: 'view_closed' }, ({ }) => { viewFn(); }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, I was looking for a way to listen to view closed actions and I stumbled upon this PR.
can you please explain why this doesn't trigger multiple listeners? why is the view_closed
action not handled by app.view('view_callback_id', ...)
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to write a listener to handle both the submission and the close action in the same function and I expected to write app.view('view_callback_id', ...)
so it catches both 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please explain why this doesn't trigger multiple listeners?
No, both listeners are triggered here. The following assertion assert.equal(viewFn.callCount, 2);
verifies if viewFn
is called twice.
Thus, as long as you set only callback_id to an app.view
listener, the listener should work as you expect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the quick reply. however, that's not what I experience. I have the following listeners:
this.boltApp.view(FEEDBACK_NOTE_CALLBACK_ID, ({body, ack}) => this.handleFeedbackNoteCallback(body, ack, 'first'))
this.boltApp.view({callback_id: FEEDBACK_NOTE_CALLBACK_ID, type: 'view_closed'}, ({body, ack}) => this.handleFeedbackNoteCallback(body, ack, 'second'))
I'm logging the "first" and "second" strings. When closing a modal, I just tested only the second function is called.
I'm on "@slack/bolt": "^3.8.1",
. Maybe this is a regression or something 🤷♂️ But I don't have time to create an issue or investigate further, as I have the solution that works. Thanks for your time.
Summary
Addresses #263 and #266
Requirements (place an
x
in each[ ]
)